Skip to main content

Full text of "Arduino"

See other formats

Using the MakerShield - Button 


Make Projects 

build, hack, tweak, share, discover,' 

Using the MakerShield - Button 

Written By: Michael Castor 


MakerShield (1) 
Arduino Uno (1) 
Mini breadboard (1) 
Jumper Wire (1) 
Resistor. 10kQ. 1/4W(1) 


The MakerShield is a great prototyping shield but the button can be a little confusing to use. 
Since it connects to ground when pressed, it takes a little extra wiring and one change in the 
code to get to work with with the Arduino example sketch. Follow along! 

© Make Projects Page 1 of 5 

Using the MakerShield - Button 

First, let's lay out our parts. You'll need a MakerShield (assembled), a mini breadboard, an 
Arduino, 3 male jumper wires, and a 10K Ohm (Brown, Black, Orange) resistor. 

Next, take your MakerShield (with mini breadboard attached) and place it on top of the 
shield headers. Make sure the pins are lined up and press it into place. 

Great Job! Let's continue. 

• Now for the parts. Take your 10K Ohm resistor (Brown, Black, Orange) and insert one leg 
into the 5V pin on the MakerShield. Connect the other leg to an adjacent hole on the 

• The reason we're doing this is to give the digital input pin something to sense. This will 
supply the voltage we need to let the input pin know that something is going on. 

• Next, take a jumper wire and insert one end into the breadboard right above the resistor 
(just like in the picture). Connect the other end of the wire to the BTN1 (button 1) pin on the 

© Make Projects 

Page 2 of 5 

Using the MakerShield - Button 

Now, grab another jumper wire and stick one end into the breadboard above the other 
jumper wire. The other end of this jumper wire will go to the D2 (digital 2) pin on the 

This wire is so that the Arduino will be able to detect when the button is pressed. 

Now we are going to connect the LED on the MakerShield to the LED output pin. 

Take another jumper wire and connect one end to the LED1 pin on the Maker Shield. 
Connect the other end of the jumper wire to pin D13 (digital 13) on the MakerShield. 

Now the LED is connected so we'll be able to see when the button is pressed. 

© Make Projects 

Page 3 of 5 

Using the MakerShield - Button 



-m r"- •:— r -x 

ji:jlii..x-3.ii..i.i ■■ 




■ ■ ■ ■ ■ . . ; 


• Go ahead and plug your Arduino into your computer using the USB port and fire up the 
Arduino software. 

• Open the Button example sketch by going to File > Examples > Digital > Button. 

• Got it? Good! This sketch is written for a button that is connected to voltage on one end 
and a digital pin on the other. The button on the Maker Shield is different; the button 
connects to ground when pressed. Because of this we need to make one little change to 
the code. 

• Scroll down to where it says if (buttonstate == high) { (highlighted in the 
picture) and change HIGH to LOW. 

• The line should now read if (buttonstate == low) { 

• What we just told the code that when the button is pressed on the Maker Shield (when the 
digital pin gets connected to ground) to light the LED up. 

© Make Projects 

Page 4 of 5 

Using the MakerShield - Button 

Now upload the code to your Arduino and hit the button on the MakerShield. The LED 
should light up! 

Congratulations! Your button now works! 

You can easily swap which LED lights up by switching your LED jumper wire from LED1 to 

Play around and have fun! 

Easy, huh? 

This document was last generated on 201 2-1 1 -02 1 0:49:29 PM. 

© Make Projects 

Page 5 of 5